package com.netbetter.langzheng.plugin.fileManager.widget.chart;

import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Frame;
import com.rednels.ofcgwt.client.model.ChartData;
import com.rednels.ofcgwt.client.model.elements.PieChart;

/**
 * @author 嘉陵江里捉鱼 email:tang7259@163.com
 *@version 1.0
 *@time Oct 13, 2008 9:58:25 PM
 */
public class SpaceChart extends Window {

    public SpaceChart() {
        this.setSize(330, 250);
        this.setFrame(true);
        Frame f = new Frame("/info/space");
        fly(f.getElement()).setStyleAttribute("frameBorder", "0");
        fly(f.getElement()).setStyleAttribute("overflow", "hidden");
        fly(f.getElement()).setStyleAttribute("width", "320");
        fly(f.getElement()).setStyleAttribute("height", "240");
        add(f);
        this.setDraggable(false);
    }
}

class TestPieChart {

    ChartData c;
    PieChart  p;

    public TestPieChart() {
        p = new PieChart();
        p.setGradientFill(true);
        p.setAnimate(false);
        p.setStartAngle(35);
        p.setBorder(2);
        p.setColours("#d01f3c", "#345678", "#356aa0", "#C79810");
        p.setTooltip("#label#<br>$#val# (#percent#)");
        p.setAlpha(0.6f);
        p.setNoLabels(true);

        c = new ChartData("Pie Chart");
        c.addElements(p);
        c.setBackgroundColour("#eeffee");
    }

    public String getJSON() {
        p.getValues().clear();
        int n = Random.nextInt(6) + 2;
        for (int i = 0; i < n; i++) {
            p.addSlice(Random.nextInt(12) * 1000, "Slice #" + (i + 1));
        }
        return c.toString();
    }
}
